package com.czhlearn.mapper;

import com.czhlearn.pojo.Category;
import com.czhlearn.pojo.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @program: big-event
 * @description:
 * @author: czh
 * @create: 2023-12-19 10:32
 **/

@Mapper
public interface CategoryMapper {
    //添加文章分类
    @Insert("insert into category(category_name,category_alias,create_user,create_time,update_time) values " +
            "(#{categoryName}, #{categoryAlias},#{createUser},#{createTime},#{updateTime})")
    void add(Category category);

    @Select("SELECT * FROM `category` where create_user = #{id}")
   List<Category> get(Integer id);

    @Select("SELECT * FROM `category` where id = #{id}")
    Category getDetail(Integer id);

    @Update("UPDATE `category` SET category_name = #{categoryName}, `category_alias` = #{categoryAlias},`update_time` = now()  WHERE `id` = #{id}")
    void update(Category category);

    @Delete("DELETE FROM `category` WHERE `id` = #{id}")
    void delete(Integer id);
}
